<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitUpdate25 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('social_accounts', function (Blueprint $table) {
            $table->string('openid', 37)->change();
            $table->string('unionid', 37)->change();
        });

        Schema::table('users', function (Blueprint $table) {
            $table->integer('device_id')->nullable()->index()->comment('设备标记id');
            $table->json('device_info')->nullable()->comment('其它设备信息');

            $table->timestamp('marked_at')->nullable()->comment('标记时间');
        });

        Schema::table('orders', function (Blueprint $table) {
            $table->integer('device_id')->nullable()->index()->comment('设备标记id');
            $table->json('device_info')->nullable()->comment('其它设备信息');
        });

        Schema::table('visitors', function (Blueprint $table) {
            $table->integer('device_id')->nullable()->index()->comment('设备标记id');
            $table->json('device_info')->nullable()->comment('其它设备信息');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('device_id');
            $table->dropColumn('device_info');
        });

        Schema::table('orders', function (Blueprint $table) {
            $table->dropColumn('device_id');
            $table->dropColumn('device_info');
        });

        Schema::table('visitors', function (Blueprint $table) {
            $table->dropColumn('device_id');
            $table->dropColumn('device_info');
        });
    }
}
